package com.fxd.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @auther fuxudong
 * @date 2021/5/2 - 17:09
 */
@Configuration
public class GateWayConfig {

    @Bean
    public RouteLocator customRouteLoator(RouteLocatorBuilder routeLocatorBuilder) {
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
//        当访问localhost：9527/guonei是会自动转发到地址：http://news.baidu.com/guonei
        routes.route("path_route_1",
                r -> r.path("/guonei")
                        .uri("http://news.baidu.com/guonei")).build();
        return routes.build();
    }
}
